Public Class MySections

    Public Class SectionException
        Inherits Exception

        Public Sub New(ByVal message As String)
            MyBase.New(message)
        End Sub

    End Class

    Private Class SectionReader
        Private m_blnWithComments As Boolean
        Private m_objText As New System.Text.StringBuilder

        Public Sub New(ByVal withComments As Boolean)
            m_blnWithComments = withComments
        End Sub

        Public Overloads Sub Read(ByVal region As Integer)
            If m_blnWithComments Then
                Dim strName As String = Language.ReadMessages("msgREGION").ToUpper + " " + region.ToString

                Me.Read("", strName + " @@@@@@@@@@@@@@@@@@@@@@@@@@", "")
            End If
        End Sub

        Public Overloads Sub Read(ByVal section As Integer, ByVal comment As String)
            Dim strName As String = Language.ReadMessages("msgSECTION").ToUpper + " " + section.ToString
            Dim strText As String = StrDup(strName.Length, "-")

            If comment Is Nothing Then
                Me.Read(strText, strName, strText)
            Else
                Me.Read(strText, strName, strText, comment)
            End If
        End Sub

        Public Overloads Sub Read(ByVal comment As String, ByVal ParamArray values() As Object)
            If values.Length = 0 Then
                If m_blnWithComments Then
                    Me.Read(New String() {comment})
                End If
            Else
                Dim aString(values.Length - 1) As String
                Dim intIndex As Integer
                Dim strValue As String

                For Each objValue As Object In values
                    If objValue.GetType Is GetType(Double) Then
                        strValue = (New CustomDoubleConverter).ConvertToString(objValue).ToString
                    Else
                        strValue = objValue.ToString
                    End If
                    strValue = strValue.Replace(System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator, DECIMAL_SEPARATOR_CHAR)
                    aString(intIndex) = strValue
                    intIndex += 1
                Next

                strValue = String.Join(VALUES_SEPARATOR_CHAR, aString)
                If m_blnWithComments Then
                    strValue = "   " + strValue + " " + PROPERTY_COMMENT_CHAR + comment
                End If

                m_objText.AppendLine(strValue)
            End If
        End Sub

        Public Overloads Sub Read(ByVal ParamArray comments() As String)
            If m_blnWithComments Then
                For Each strComment As String In comments
                    m_objText.Append(LINE_COMMENT_CHAR)
                    If strComment.Length > 0 Then
                        m_objText.Append("  " + strComment)
                    End If
                    m_objText.AppendLine()
                Next
            End If
        End Sub

        Public ReadOnly Property Text() As String
            Get
                Return m_objText.ToString
            End Get
        End Property

    End Class

    Private Class SectionWriter
        Private m_astrValues As String()
        Private m_intFieldIndex As Integer
        Private m_objTextFieldParser As FileIO.TextFieldParser

        Public Sub New(ByVal text As String)
            Dim objText As New System.Text.StringBuilder

            For Each strLine As String In text.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
                objText.AppendLine(strLine.Split(Char.Parse(PROPERTY_COMMENT_CHAR))(0))
            Next

            m_objTextFieldParser = New FileIO.TextFieldParser(New System.IO.StringReader(objText.ToString))
            With m_objTextFieldParser
                .TextFieldType = FileIO.FieldType.Delimited
                .CommentTokens = New String() {LINE_COMMENT_CHAR}
                .SetDelimiters(VALUES_SEPARATOR_CHAR)
                .TrimWhiteSpace = True
            End With
        End Sub

        Public Sub Close()
            m_objTextFieldParser.Close()
        End Sub

        Public Overloads Sub Write(ByRef value As Decimal)
            value = CDec(Me.ConvertToDouble(Me.CurrentValue))
            m_intFieldIndex += 1
        End Sub

        Public Overloads Sub Write(ByRef value As Double)
            value = Me.ConvertToDouble(Me.CurrentValue)
            m_intFieldIndex += 1
        End Sub

        Public Overloads Sub Write(ByRef value As Integer)
            value = Me.ConvertToInteger(Me.CurrentValue)
            m_intFieldIndex += 1
        End Sub

        Public Overloads Sub Write(ByRef value As Object)
            Dim intValue As Integer

            Me.Write(intValue)
            value = intValue
        End Sub

        Public Function LineNumber() As Long
            Return m_objTextFieldParser.LineNumber
        End Function

        Public Sub NextLine()
            If m_objTextFieldParser.EndOfData Then
                Throw New IO.InvalidDataException
            Else
                m_astrValues = m_objTextFieldParser.ReadFields()
                m_intFieldIndex = 0
            End If
        End Sub


        Private Function ConvertToDouble(ByVal value As String) As Double
            Return CType((New CustomDoubleConverter).ConvertFrom(value), Double)
        End Function

        Private Function ConvertToInteger(ByVal value As String) As Integer
            Return Integer.Parse(value)
        End Function

        Private Function CurrentValue() As String
            Return m_astrValues(m_intFieldIndex).Replace(DECIMAL_SEPARATOR_CHAR, System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)
        End Function

    End Class

    Private Const DECIMAL_SEPARATOR_CHAR As String = "."
    Private Const LINE_COMMENT_CHAR As String = "C"
    Private Const PROPERTY_COMMENT_CHAR As String = "!"
    Private Const VALUES_SEPARATOR_CHAR As String = ","

    Private m_blnModified As Boolean
    Private m_lngErrorLineNumber As Long
    Private WithEvents m_objMyRegions As New MyRegions
    Private WithEvents m_objMyWavelengths As New MyWavelengths
    Private m_SectionList As New List(Of BaseDescriptor)
    Private m_strCurrentText As String

    Public Event Changed()

    Public Sub New()
        m_SectionList.Add(New Section1) : My.Application.DoEvents()
        m_SectionList.Add(New Section2) : My.Application.DoEvents()
        m_SectionList.Add(New Section3) : My.Application.DoEvents()
        m_SectionList.Add(New Section4) : My.Application.DoEvents()
        m_SectionList.Add(Nothing) : My.Application.DoEvents()
        m_SectionList.Add(Nothing) : My.Application.DoEvents()
        m_SectionList.Add(New Section7) : My.Application.DoEvents()
        m_SectionList.Add(New Section8) : My.Application.DoEvents()
        m_SectionList.Add(New Section9) : My.Application.DoEvents()
        m_SectionList.Add(Nothing) : My.Application.DoEvents()
        Me.RefreshWavelengths()
        m_strCurrentText = Me.Read
    End Sub

    Public Function ErrorLineNumber() As Long
        Return m_lngErrorLineNumber
    End Function

    Public Function HasRegions(ByVal section As Integer) As Boolean
        Select Case section
            Case 5, 6, 10
                Return True
            Case Else
                Return False
        End Select
    End Function

    Public Overloads ReadOnly Property Item(ByVal section As Integer) As BaseDescriptor
        Get
            Return m_SectionList.Item(section - 1)
        End Get
    End Property

    Public Overloads ReadOnly Property Item(ByVal section As Integer, ByVal region As Integer) As BaseDescriptor
        Get
            Select Case section
                Case 5
                    Return m_objMyRegions.Item(region).Section5
                Case 6
                    Return m_objMyRegions.Item(region).Section6
                Case 10
                    Return m_objMyRegions.Item(region).Section10
                Case Else
                    Return Me.Item(section)
            End Select
        End Get
    End Property

    Public Shared Function ItemList() As List(Of String)
        Dim NewList As New List(Of String)

        For intItem As Integer = 1 To 10
            NewList.Add(Language.ReadMessages("msgSECTION") + " " + intItem.ToString)
        Next

        Return NewList
    End Function

    Public ReadOnly Property Modified() As Boolean
        Get
            Return m_blnModified
        End Get
    End Property

    Public Function Read(Optional ByVal withComments As Boolean = True) As String
        If Me.ErrorLineNumber = 0 Then
            Dim objSectionReader As New SectionReader(withComments)

            Try
                Me.ReadSection1(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection2(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection3(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection4(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection5(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection6(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection7(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection8(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection9(objSectionReader) : My.Application.DoEvents()
                Me.ReadSection10(objSectionReader) : My.Application.DoEvents()
            Catch ex As Exception
                Throw New SectionException(ex.Message)
            End Try

            Return objSectionReader.Text
        Else
            Return m_strCurrentText
        End If
    End Function

    Public Function ReadHtml(ByVal title As String) As String
        Dim intLine As Integer = 1
        Dim objTextHtml As New System.Text.StringBuilder

        objTextHtml.Append("<html>")
        objTextHtml.Append("<title>" + IIf(title Is Nothing, "", title).ToString + "</title>")
        objTextHtml.Append("<body>")
        objTextHtml.Append("<font face='Courier New' color='black'>")
        For Each strLine As String In Me.Read.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
            If Me.ErrorLineNumber <> 0 AndAlso intLine >= Me.ErrorLineNumber Then
                objTextHtml.Append("<font color='red'>" + strLine + "</font>")
            Else
                If strLine.StartsWith(LINE_COMMENT_CHAR) Then
                    objTextHtml.Append("<font color=#008000>" + strLine + "</font>")
                Else
                    Dim intCharIndex As Integer = strLine.IndexOf(PROPERTY_COMMENT_CHAR)

                    If intCharIndex >= 0 Then
                        objTextHtml.Append(strLine.Substring(0, intCharIndex) + "<font color=#008000>" + strLine.Substring(intCharIndex) + "</font>")
                    Else
                        objTextHtml.Append(strLine)
                    End If
                End If
            End If
            objTextHtml.Append("</br>")
            intLine += 1
        Next
        objTextHtml.Append("</font>")
        objTextHtml.Append("</body>")
        objTextHtml.Append("</html>")

        Return objTextHtml.ToString
    End Function

    Public Function ReadRtf() As String
        Dim intLine As Integer = 1
        Dim objTextRtf As New System.Text.StringBuilder

        objTextRtf.Append("{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl}")
        objTextRtf.Append("{\colortbl;\red0\green128\blue0;\red255\green0\blue0;}")
        objTextRtf.Append("\viewkind4\uc1\pard\f0\fs20")
        For Each strLine As String In Me.Read.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
            If Me.ErrorLineNumber <> 0 AndAlso intLine >= Me.ErrorLineNumber Then
                objTextRtf.Append("\cf2 " + strLine + "\cf0 ")
            Else
                If strLine.StartsWith(LINE_COMMENT_CHAR) Then
                    objTextRtf.Append("\cf1 " + strLine + "\cf0 ")
                Else
                    Dim intCharIndex As Integer = strLine.IndexOf(PROPERTY_COMMENT_CHAR)

                    If intCharIndex >= 0 Then
                        objTextRtf.Append(strLine.Substring(0, intCharIndex) + "\cf1 " + strLine.Substring(intCharIndex) + "\cf0 ")
                    Else
                        objTextRtf.Append(strLine)
                    End If
                End If
            End If
            objTextRtf.Append("\par ")
            intLine += 1
        Next

        Return objTextRtf.ToString
    End Function

    Public ReadOnly Property Regions() As MyRegions
        Get
            Return m_objMyRegions
        End Get
    End Property

    Public ReadOnly Property Section1() As Section1
        Get
            Return CType(Me.Item(1), Section1)
        End Get
    End Property

    Public ReadOnly Property Section2() As Section2
        Get
            Return CType(Me.Item(2), Section2)
        End Get
    End Property

    Public ReadOnly Property Section3() As Section3
        Get
            Return CType(Me.Item(3), Section3)
        End Get
    End Property

    Public ReadOnly Property Section4() As Section4
        Get
            Return CType(Me.Item(4), Section4)
        End Get
    End Property

    Public ReadOnly Property Section5(ByVal region As Integer) As Section5
        Get
            Return CType(Me.Item(5, region), Section5)
        End Get
    End Property

    Public ReadOnly Property Section6(ByVal region As Integer) As Section6
        Get
            Return CType(Me.Item(6, region), Section6)
        End Get
    End Property

    Public ReadOnly Property Section7() As Section7
        Get
            Return CType(Me.Item(7), Section7)
        End Get
    End Property

    Public ReadOnly Property Section8() As Section8
        Get
            Return CType(Me.Item(8), Section8)
        End Get
    End Property

    Public ReadOnly Property Section9() As Section9
        Get
            Return CType(Me.Item(9), Section9)
        End Get
    End Property

    Public ReadOnly Property Section10(ByVal region As Integer) As Section10
        Get
            Return CType(Me.Item(10, region), Section10)
        End Get
    End Property

    Public ReadOnly Property Wavelengths() As MyWavelengths
        Get
            Return m_objMyWavelengths
        End Get
    End Property

    Public Sub Write(ByVal text As String)
        If m_strCurrentText = text Then
            m_blnModified = False
        Else
            Dim objSectionWriter As New SectionWriter(text)

            m_blnModified = True
            m_lngErrorLineNumber = 0
            m_strCurrentText = text
            Try
                Me.WriteSection1(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection2(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection3(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection4(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection5(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection6(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection7(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection8(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection9(objSectionWriter) : My.Application.DoEvents()
                Me.WriteSection10(objSectionWriter) : My.Application.DoEvents()
                m_strCurrentText = Me.Read
            Catch ex As Exception
                m_lngErrorLineNumber = objSectionWriter.LineNumber - 1
                Throw New SectionException(ex.Message)
            Finally
                objSectionWriter.Close()
                RaiseEvent Changed()
            End Try
        End If
    End Sub


    Private Sub m_objMyRegions_Changed() Handles m_objMyRegions.Changed
        Me.RefreshWavelengthsSection10()
        RaiseEvent Changed()
    End Sub

    Private Sub m_objMyWavelengths_Changed() Handles m_objMyWavelengths.Changed
        Me.RefreshWavelengths()
        RaiseEvent Changed()
    End Sub


    Private Sub ReadSection1(ByVal sr As SectionReader)
        sr.Read(1, Language.ReadProperties("S1C1") + " - " + Language.ReadProperties("S1C2"))
        With Me.Section1
            sr.Read("STV1, VJUMP1, STV2, VJUMP2, STV3, VJUMP3, STV4", .STV1, .VJUMP1, .STV2, .VJUMP2, .STV3, .VJUMP3, .STV4)
            sr.Read("VOLT1, VOLT2", .VOLT1, .VOLT2)
            sr.Read("", Language.ReadProperties("S1C3"), "")
            sr.Read("ILIGHT1, LIGHT-X-1", .ILIGHT1, .LIGHT_X_1)
            sr.Read("ILIGHT2, LIGHT-X-2", .ILIGHT2, .LIGHT_X_2)
            sr.Read("", Language.ReadProperties("S1C4") + " - " + Language.ReadProperties("S1C5"), "")
            sr.Read("NIP", .NIP)
            sr.Read("IRSRSH, RS, RSH", .IRSRSH, .RS, .RSH)
            sr.Read("", Language.ReadProperties("S1C6"), "")
            sr.Read("ISR", .ISR)
            sr.Read("NWAVES", m_objMyWavelengths.Count)
            sr.Read("ISRBOTH, SRFLUX", .ISRBOTH, .SRFLUX)
        End With
    End Sub

    Private Sub ReadSection2(ByVal sr As SectionReader)
        sr.Read(2, Language.ReadProperties("S2C1"))
        With Me.Section2
            sr.Read("NDARK", .NDARK)
            For intIndex As Integer = 1 To .NDARK
                sr.Read("VDARK(" + intIndex.ToString + ")", .VDARK(intIndex - 1))
            Next
            sr.Read("NLIGHT", .NLIGHT)
            For intIndex As Integer = 1 To .NLIGHT
                sr.Read("VLIGHT(" + intIndex.ToString + ")", .VLIGHT(intIndex - 1))
            Next
            sr.Read("NSR", .NSR)
            For intIndex As Integer = 1 To .NSR
                sr.Read("VSR(" + intIndex.ToString + ")", .VSR(intIndex - 1))
            Next
            sr.Read("", Language.ReadProperties("S2C2"), "")
            sr.Read("NOUTFILE", .NOUTFILE)
        End With
    End Sub

    Private Sub ReadSection3(ByVal sr As SectionReader)
        sr.Read(3, Language.ReadProperties("S3C1"))
        With Me.Section3
            sr.Read("T", .T)
            sr.Read("IFFVOC", .IFFVOC)
            sr.Read("", Language.ReadProperties("S3C2") + " - " + Language.ReadProperties("S3C3"), "")
            sr.Read("PSIB0, SN0, SP0, RITOP", .PSIB0, .SN0, .SP0, .RITOP)
            sr.Read("PSIBL, SNL, SPL, RIBOT", .PSIBL, .SNL, .SPL, .RIBOT)
            sr.Read("", Language.ReadProperties("S3C4"), "")
            sr.Read("TFREEZ, IHDIP, SISIN", .TFREEZ, .IHDIP, .SISIN)
            sr.Read("DPEXT", .DPEXT)
            sr.Read("", Language.ReadProperties("S3C5"), "")
            sr.Read("POLFAC", .POLFAC)
            sr.Read("", Language.ReadProperties("S3C6"), "")
            sr.Read("SCA-MAXANG, SCA-MINANG", .SCA_MAXANG, .SCA_MINANG)
        End With
    End Sub

    Private Sub ReadSection4(ByVal sr As SectionReader)
        sr.Read(4, Language.ReadProperties("S4C1"))
        With Me.Section4
            sr.Read("INTER", .INTER)
            sr.Read("IOLAY", .IOLAY)
            sr.Read("IS", .IS)
            sr.Read("ILBACK", .ILBACK)
            sr.Read("ISHIFTAL", .ISHIFTAL)
            sr.Read("", Language.ReadProperties("S4C2"), "")
            sr.Read("IGENREC", .IGENREC)
            sr.Read("IENERGY", .IENERGY)
            sr.Read("IFIEMO, REFFIELD", .IFIEMOB, .REFFIELD)
            sr.Read("ITUNN, IEFMA", .ITUNN, .IEFMA)
        End With
    End Sub

    Private Sub ReadSection5(ByVal sr As SectionReader)
        sr.Read(5, "")
        sr.Read("NRGS", m_objMyRegions.Count)
        For intRegion As Integer = 1 To m_objMyRegions.Count
            With Me.Section5(intRegion)
                sr.Read(intRegion)
                sr.Read("IAMP", .IAMP)
                sr.Read("IDEP", .IDEP)
                sr.Read("IFEPO", .IFEPO)
                sr.Read("ITUBA, ITURE", .ITUBA, .ITURE)
                sr.Read("ITAT", .ITAT)
                sr.Read("ITATFP", .ITATFP)
                sr.Read("IFIECS", .IFIECS)
                sr.Read("IFIEMO", .IFIEMO)
                sr.Read("IFIENCNV", .IFIENCNV)
                sr.Read("IDAUG, CNAUG, CPAUG", .IDAUG, .CNAUG, .CPAUG)
                sr.Read("IDREC, CDRAD, TAUMIN", .IDREC, .CDRAD, .TAUMIN)
                sr.Read("IBBTU, ABBT, BBBT, CBBT", .IBBTU, .ABBT, .BBBT, .CBBT)
                sr.Read("CLEN", .CLEN)
            End With
        Next
    End Sub

    Private Sub ReadSection6(ByVal sr As SectionReader)
        Dim intIndex As Integer
        Dim strComment As String

        sr.Read(6, Nothing)
        For intRegion As Integer = 1 To m_objMyRegions.Count
            With Me.Section6(intRegion)
                sr.Read(intRegion)
                sr.Read(Language.ReadProperties("S6C1"))
                sr.Read("W-LAYER", .W_LAYER)
                With .GRID
                    sr.Read("NSTEP, IPEAK, STFACT", .NSTEP, .IPEAK, .STFACT)
                End With
                With .DL
                    sr.Read("DLVS", .DLVS)
                    If CInt(.DLVS) = 0 Then
                        sr.Read("ND,EDOND,SDD,GR(ND)", .ND, 0, 0, 0)
                        '0.9.5
                        'sr.Read("DSIG/ND,DSIG/PD", 0, 0)
                        sr.Read("DDF,DSIG/ND,DSIG/PD", 0, 0, 0)
                    Else
                        For intIndex = 1 To CInt(.DLVS)
                            strComment = "ND(" + intIndex.ToString + "),"
                            strComment += "EDOND(" + intIndex.ToString + "),"
                            strComment += "SDD(" + intIndex.ToString + "),"
                            strComment += "GR(ND)(" + intIndex.ToString + ")"
                            '0.9.5
                            'With .DLEVELS(intIndex)
                            With .DLEVELS(intIndex - 1)
                                sr.Read(strComment, .ND, .EDOND, .SDD, .GR_ND)
                            End With
                            strComment = "DDF(" + intIndex.ToString + "),"  '0.9.5
                            strComment += "DSIG/ND(" + intIndex.ToString + "),"
                            strComment += "DSIG/PD(" + intIndex.ToString + ")"
                            With .DLEVELS(intIndex - 1)
                                '0.9.5
                                'sr.Read(strComment, .DSIG_ND, .DSIG_PD)
                                sr.Read(strComment, .DDF, .DSIG_ND, .DSIG_PD)
                            End With
                        Next
                    End If
                End With
                With .AL
                    sr.Read("ALVS", .ALVS)
                    If CInt(.ALVS) = 0 Then
                        sr.Read("NA,EACPD,SDA,GR(NA)", .NA, 0, 0, 0)
                        '0.9.5
                        'sr.Read("DSIG/NA,DSIG/PA", 0, 0)
                        sr.Read("ADF,DSIG/NA,DSIG/PA", 0, 0, 0)
                    Else
                        For intIndex = 1 To CInt(.ALVS)
                            strComment = "NA(" + intIndex.ToString + "),"
                            strComment += "EACPD(" + intIndex.ToString + "),"
                            strComment += "SDA(" + intIndex.ToString + "),"
                            strComment += "GR(NA)(" + intIndex.ToString + ")"
                            '0.9.5
                            'With .ALEVELS(intIndex)
                            With .ALEVELS(intIndex - 1)
                                sr.Read(strComment, .NA, .EACPD, .SDA, .GR_NA)
                            End With
                            strComment = "ADF(" + intIndex.ToString + "),"  '0.9.5
                            strComment += "DSIG/NA(" + intIndex.ToString + "),"
                            strComment += "DSIG/PA(" + intIndex.ToString + ")"
                            With .ALEVELS(intIndex - 1)
                                '0.9.5
                                'sr.Read(strComment, .DSIG_NA, .DSIG_PA)
                                sr.Read(strComment, .ADF, .DSIG_NA, .DSIG_PA)
                            End With
                        Next
                    End If
                End With
                sr.Read("", Language.ReadProperties("S6C2"), "")
                With .DG
                    sr.Read("NUMDG", .NUMDG)
                    For intIndex = 1 To CInt(.NUMDG)
                        strComment = "NDG,PEDG,SDDG,GR(NDG),GR(PEDG),GR(SDDG) (G-" + intIndex.ToString + ")"
                        With .DGAUSSIANS(intIndex - 1)
                            sr.Read(strComment, .NDG, .PEDG, .SDDG, .GR_NDG, .GR_PEDG, .GR_SDDG)
                        End With
                    Next
                    For intIndex = 1 To CInt(.NUMDG)
                        strComment = "GSIG/ND,GSIG/PD,GR(GSIG/ND),GR(GSIG/PD) (G-" + intIndex.ToString + ")"
                        With .DGAUSSIANS(intIndex - 1)
                            sr.Read(strComment, .GSIG_ND, .GSIG_PD, .GR_GSIG_ND, .GR_GSIG_PD)
                        End With
                    Next
                End With
                With .AG
                    sr.Read("NUMAG", .NUMAG)
                    For intIndex = 1 To CInt(.NUMAG)
                        strComment = "NAG,PEAG,SDAG,GR(NAG),GR(PEAG),GR(SDAG) (G-" + intIndex.ToString + ")"
                        With .AGAUSSIANS(intIndex - 1)
                            sr.Read(strComment, .NAG, .PEAG, .SDAG, .GR_NAG, .GR_PEAG, .GR_SDAG)
                        End With
                    Next
                    For intIndex = 1 To CInt(.NUMAG)
                        strComment = "GSIG/NA,GSIG/PA,GR(GSIG/NA),GR(GSIG/PA) (G-" + intIndex.ToString + ")"
                        With .AGAUSSIANS(intIndex - 1)
                            sr.Read(strComment, .GSIG_NA, .GSIG_PA, .GR_GSIG_NA, .GR_GSIG_PA)
                        End With
                    Next
                End With
                sr.Read("", Language.ReadProperties("S6C3"), "")
                With .TAILS
                    sr.Read("GDO, GAO, GR(GDO), GR(GAO)", .GDO, .GAO, .GR_GDO, .GR_GAO)
                    sr.Read("ED, EA, GR(ED), GR(EA)", .ED, .EA, .GR_ED, .GR_EA)
                    sr.Read("TSIG/ND, TSIG/PD, GR(TSIG/ND), GR(TSIG/PD)", .TSIG_ND, .TSIG_PD, .GR_TSIG_ND, .GR_TSIG_PD)
                    sr.Read("TSIG/NA, TSIG/PA, GR(TSIG/NA), GR(TSIG/PA)", .TSIG_NA, .TSIG_PA, .GR_TSIG_NA, .GR_TSIG_PA)
                End With
                sr.Read("NTRAP", .NTRAP)
                With .MIDGAP
                    sr.Read("MDDS, MADS, EDA, GR(MDDS), GR(MADS), GR(EDA)", .MDDS, .MADS, .EDA, .GR_MDDS, .GR_MADS, .GR_EDA)
                    sr.Read("MSIG/ND, MISG/PD, GR(MSIG/ND), GR(MSIG/PD)", .MSIG_ND, .MISG_PD, .GR_MSIG_ND, .GR_MSIG_PD)
                    sr.Read("MSIG/NA, MISG/PA, GR(MSIG/NA), GR(MSIG/PA)", .MSIG_NA, .MISG_PA, .GR_MSIG_NA, .GR_MSIG_PA)
                End With
                sr.Read("", Language.ReadProperties("S6C4"), "")
                sr.Read("HCON, UCODP, GR(HCON), GR(UCODP)", .HCON, .UCODP, .GR_HCON, .GR_UCODP)
                sr.Read("EPDP, DELTADP, GR(EPDP), GR(DELTADP)", .EPDP, .DELTADP, .GR_EPDP, .GR_DELTADP)
                sr.Read("", Language.ReadProperties("S6C5"), "")
                With .EDOS
                    sr.Read("NC, NV, GR(NC), GR(NV)", .NC, .NV, .GR_NV, .GR_NC)
                End With
                With .GAP
                    sr.Read("EG, EGOPT, GR(EG), GR(ALPHA)", .EG, .EGOPT, .GR_EG, .GR_ALPHA)
                    sr.Read("AEGOPT, DEGOPT", .AEGOPT, .DEGOPT)
                End With
                With .AFF
                    sr.Read("EAFF, GR(EAFF)", .EAFF, .GR_EAFF)
                    sr.Read("EPS, GR(EPS)", .EPS, .GR_EPS)
                End With
                With .FCM
                    sr.Read("EMOB, HMOB, GR(EMOB), GR(HMOB)", .EMOB, .HMOB, .GR_EMOB, .GR_HMOB)
                End With
                sr.Read("", Language.ReadProperties("S6C6"), "")
                With .EMASSES
                    sr.Read("EEFM, HEFM, GR(EEFM), GR(HEFM)", .EEFM, .HEFM, .GR_EEFM, .GR_HEFM)
                End With
                With .MTUNN
                    sr.Read("RLOC/MT, DLOC/MT, GR(RLOC), GR(DLOC)", .RLOC_MT, .DLOC_MT, .GR_RLOC, .GR_DLOC)
                End With
                sr.Read("", Language.ReadProperties("S6C7"), "")
                sr.Read("SCA-MAXANG, SCA-MINANG", .SCA_MAXANG, .SCA_MINANG)
            End With
        Next
    End Sub

    Private Sub ReadSection7(ByVal sr As SectionReader)
        sr.Read(7, "LAMBDA,FLUX(1),IFLUX,FILTER,FLUX(2)")
        With Me.Section7
            For intIndex As Integer = 1 To .Items.Count
                With .Items.Item(intIndex - 1)
                    sr.Read("LAMBDA(" + intIndex.ToString + ")", .LAMBDA, .FLUX_1, .IFLUX, .FILTER, .FLUX_2)
                End With
            Next
        End With
    End Sub

    Private Sub ReadSection8(ByVal sr As SectionReader)
        '0.9.6
        'sr.Read(8, "LAMBDA,N-FOL-1,K-FOL-1,N-FOL-2,K-FOL-2")
        sr.Read(8, "LAMBDA,N-EFOL,K-EFOL,N-IFOL,K-IFOL")

        With Me.Section8
            '0.9.6
            'sr.Read("W(FOL-1), W(FOL-2)", .W_EFOL, .W_IFOL)
            sr.Read("W(EFOL), W(IFOL)", .W_EFOL, .W_IFOL)

            For intIndex As Integer = 1 To .Items.Count
                With .Items.Item(intIndex - 1)
                    sr.Read("LAMBDA(" + intIndex.ToString + ")", .LAMBDA, .N_EFOL, .K_EFOL, .N_IFOL, .K_IFOL)
                End With
            Next
        End With
    End Sub

    Private Sub ReadSection9(ByVal sr As SectionReader)
        '0.9.6
        'sr.Read(9, "LAMBDA,N-BOL-1,K-BOL-1,N-BOL-2,K-BOL-2")
        sr.Read(9, "LAMBDA,N-IBOL,K-IBOL,N-EBOL,K-EBOL")

        With Me.Section9
            '0.9.6
            'sr.Read("W(BOL-1), W(BOL-2)", .W_IBOL, .W_EBOL)
            sr.Read("W(IBOL), W(EBOL)", .W_IBOL, .W_EBOL)

            For intIndex As Integer = 1 To .Items.Count
                With .Items.Item(intIndex - 1)
                    sr.Read("LAMBDA(" + intIndex.ToString + ")", .LAMBDA, .N_IBOL, .K_IBOL, .N_EBOL, .K_EBOL)
                End With
            Next
        End With
    End Sub

    Private Sub ReadSection10(ByVal sr As SectionReader)
        sr.Read(10, "LAMBDA,RILAM,ALPHA")
        For intRegion As Integer = 1 To m_objMyRegions.Count
            With Me.Section10(intRegion)
                sr.Read(intRegion)
                For intIndex As Integer = 1 To .Items.Count
                    With .Items.Item(intIndex - 1)
                        sr.Read("LAMBDA(" + intIndex.ToString + ")", .LAMBDA, .RILAM, .ALPHA)
                    End With
                Next
            End With
        Next
    End Sub

    Private Sub RefreshWavelengths()
        Me.RefreshWavelengthsSection7() : My.Application.DoEvents()
        Me.RefreshWavelengthsSection8() : My.Application.DoEvents()
        Me.RefreshWavelengthsSection9() : My.Application.DoEvents()
        Me.RefreshWavelengthsSection10() : My.Application.DoEvents()
    End Sub

    Private Sub RefreshWavelengthsSection7()
        Dim objVFLUXList As New List(Of Section7.SectionVFLUX)

        For Each objVFLUX As Section7.SectionVFLUX In Me.Section7.Items
            objVFLUXList.Add(CType(objVFLUX.Clone(), Section7.SectionVFLUX))
        Next

        Me.Section7.Items.Clear()
        For intWavelength As Integer = 1 To m_objMyWavelengths.Count
            Dim dblLAMBDA As Double = m_objMyWavelengths.Item(intWavelength)
            Dim blnExists As Boolean = False
            Dim objVFLUX As Section7.SectionVFLUX

            For Each objVFLUX In objVFLUXList
                If objVFLUX.LAMBDA = dblLAMBDA Then
                    Me.Section7.Items.Add(objVFLUX)
                    blnExists = True
                    Exit For
                End If
            Next
            If Not blnExists Then
                objVFLUX = New Section7.SectionVFLUX
                objVFLUX.LAMBDA = dblLAMBDA
                Me.Section7.Items.Add(objVFLUX)
            End If
        Next
    End Sub

    Private Sub RefreshWavelengthsSection8()
        Dim objVFOLList As New List(Of Section8.SectionVFOL)

        For Each objVFOL As Section8.SectionVFOL In Me.Section8.Items
            objVFOLList.Add(CType(objVFOL.Clone(), Section8.SectionVFOL))
        Next

        Me.Section8.Items.Clear()
        For intWavelength As Integer = 1 To m_objMyWavelengths.Count
            Dim dblLAMBDA As Double = m_objMyWavelengths.Item(intWavelength)
            Dim blnExists As Boolean = False
            Dim objVFOL As Section8.SectionVFOL

            For Each objVFOL In objVFOLList
                If objVFOL.LAMBDA = dblLAMBDA Then
                    Me.Section8.Items.Add(objVFOL)
                    blnExists = True
                    Exit For
                End If
            Next
            If Not blnExists Then
                objVFOL = New Section8.SectionVFOL
                objVFOL.LAMBDA = dblLAMBDA
                Me.Section8.Items.Add(objVFOL)
            End If
        Next
    End Sub

    Private Sub RefreshWavelengthsSection9()
        Dim objVBOLList As New List(Of Section9.SectionVBOL)

        For Each objVBOL As Section9.SectionVBOL In Me.Section9.Items
            objVBOLList.Add(CType(objVBOL.Clone(), Section9.SectionVBOL))
        Next

        Me.Section9.Items.Clear()
        For intWavelength As Integer = 1 To m_objMyWavelengths.Count
            Dim dblLAMBDA As Double = m_objMyWavelengths.Item(intWavelength)
            Dim blnExists As Boolean = False
            Dim objVBOL As Section9.SectionVBOL

            For Each objVBOL In objVBOLList
                If objVBOL.LAMBDA = dblLAMBDA Then
                    Me.Section9.Items.Add(objVBOL)
                    blnExists = True
                    Exit For
                End If
            Next
            If Not blnExists Then
                objVBOL = New Section9.SectionVBOL
                objVBOL.LAMBDA = dblLAMBDA
                Me.Section9.Items.Add(objVBOL)
            End If
        Next
    End Sub

    Private Sub RefreshWavelengthsSection10()
        For intRegion As Integer = 1 To m_objMyRegions.Count
            Dim objSection10 As Section10 = Me.Section10(intRegion)
            Dim objVOPList As New List(Of Section10.SectionVOP)

            For Each objVOP As Section10.SectionVOP In objSection10.Items
                objVOPList.Add(CType(objVOP.Clone(), Section10.SectionVOP))
            Next

            objSection10.Items.Clear()
            For intWavelength As Integer = 1 To m_objMyWavelengths.Count
                Dim dblLAMBDA As Double = m_objMyWavelengths.Item(intWavelength)
                Dim blnExists As Boolean = False
                Dim objVOP As Section10.SectionVOP

                For Each objVOP In objVOPList
                    If objVOP.LAMBDA = dblLAMBDA Then
                        objSection10.Items.Add(objVOP)
                        blnExists = True
                        Exit For
                    End If
                Next
                If Not blnExists Then
                    objVOP = New Section10.SectionVOP
                    objVOP.LAMBDA = dblLAMBDA
                    objSection10.Items.Add(objVOP)
                End If
            Next
        Next
    End Sub

    Private Sub WriteSection1(ByVal sw As SectionWriter)
        With Me.Section1
            sw.NextLine()
            sw.Write(.STV1)
            sw.Write(.VJUMP1)
            sw.Write(.STV2)
            sw.Write(.VJUMP2)
            sw.Write(.STV3)
            sw.Write(.VJUMP3)
            sw.Write(.STV4)

            sw.NextLine()
            sw.Write(.VOLT1)
            sw.Write(.VOLT2)

            sw.NextLine()
            sw.Write(.ILIGHT1)
            sw.Write(.LIGHT_X_1)

            sw.NextLine()
            sw.Write(.ILIGHT2)
            sw.Write(.LIGHT_X_2)

            sw.NextLine()
            sw.Write(.NIP)

            sw.NextLine()
            sw.Write(.IRSRSH)
            sw.Write(.RS)
            sw.Write(.RSH)

            sw.NextLine()
            sw.Write(.ISR)

            Dim NWAVES As Integer
            sw.NextLine()
            sw.Write(NWAVES)
            m_objMyWavelengths.Resize(NWAVES)

            sw.NextLine()
            sw.Write(.ISRBOTH)
            sw.Write(.SRFLUX)
        End With
    End Sub

    Private Sub WriteSection2(ByVal sw As SectionWriter)
        With Me.Section2
            sw.NextLine()
            sw.Write(.NDARK)
            If .NDARK > 0 Then
                For intIndex As Integer = 0 To .NDARK - 1
                    sw.NextLine()
                    sw.Write(.VDARK(intIndex))
                Next
            End If

            sw.NextLine()
            sw.Write(.NLIGHT)
            If .NLIGHT > 0 Then
                For intIndex As Integer = 0 To .NLIGHT - 1
                    sw.NextLine()
                    sw.Write(.VLIGHT(intIndex))
                Next
            End If

            sw.NextLine()
            sw.Write(.NSR)
            If .NSR > 0 Then
                For intIndex As Integer = 0 To .NSR - 1
                    sw.NextLine()
                    sw.Write(.VSR(intIndex))
                Next
            End If

            '0.9.5
            '.SortValues()
            .SortValues(Me.Section1.VOLT1, Me.Section1.VOLT2)

            sw.NextLine()
            sw.Write(.NOUTFILE)
        End With
    End Sub

    Private Sub WriteSection3(ByVal sw As SectionWriter)
        With Me.Section3
            sw.NextLine()
            sw.Write(.T)

            sw.NextLine()
            sw.Write(.IFFVOC)

            sw.NextLine()
            sw.Write(.PSIB0)
            sw.Write(.SN0)
            sw.Write(.SP0)
            sw.Write(.RITOP)

            sw.NextLine()
            sw.Write(.PSIBL)
            sw.Write(.SNL)
            sw.Write(.SPL)
            sw.Write(.RIBOT)

            sw.NextLine()
            sw.Write(.TFREEZ)
            sw.Write(.IHDIP)
            sw.Write(.SISIN)

            sw.NextLine()
            sw.Write(.DPEXT)

            sw.NextLine()
            sw.Write(.POLFAC)

            sw.NextLine()
            sw.Write(.SCA_MAXANG)
            sw.Write(.SCA_MINANG)
        End With
    End Sub

    Private Sub WriteSection4(ByVal sw As SectionWriter)
        With Me.Section4
            sw.NextLine()
            sw.Write(.INTER)

            sw.NextLine()
            sw.Write(.IOLAY)

            sw.NextLine()
            sw.Write(.IS)

            sw.NextLine()
            sw.Write(.ILBACK)

            sw.NextLine()
            sw.Write(.ISHIFTAL)

            sw.NextLine()
            sw.Write(.IGENREC)

            sw.NextLine()
            sw.Write(.IENERGY)

            sw.NextLine()
            sw.Write(.IFIEMOB)
            sw.Write(.REFFIELD)

            sw.NextLine()
            sw.Write(.ITUNN)
            sw.Write(.IEFMA)
        End With
    End Sub

    Private Sub WriteSection5(ByVal sw As SectionWriter)
        Dim NRGS As Integer
        sw.NextLine()
        sw.Write(NRGS)
        m_objMyRegions.Resize(NRGS)

        For intRegion As Integer = 1 To m_objMyRegions.Count
            With Me.Section5(intRegion)
                sw.NextLine()
                sw.Write(.IAMP)

                sw.NextLine()
                sw.Write(.IDEP)

                sw.NextLine()
                sw.Write(.IFEPO)

                sw.NextLine()
                sw.Write(.ITUBA)
                sw.Write(.ITURE)

                sw.NextLine()
                sw.Write(.ITAT)

                sw.NextLine()
                sw.Write(.ITATFP)

                sw.NextLine()
                sw.Write(.IFIECS)

                sw.NextLine()
                sw.Write(.IFIEMO)

                sw.NextLine()
                sw.Write(.IFIENCNV)

                sw.NextLine()
                sw.Write(.IDAUG)
                sw.Write(.CNAUG)
                sw.Write(.CPAUG)

                sw.NextLine()
                sw.Write(.IDREC)
                sw.Write(.CDRAD)
                sw.Write(.TAUMIN)

                sw.NextLine()
                sw.Write(.IBBTU)
                sw.Write(.ABBT)
                sw.Write(.BBBT)
                sw.Write(.CBBT)

                sw.NextLine()
                sw.Write(.CLEN)
            End With
        Next
    End Sub

    Private Sub WriteSection6(ByVal sw As SectionWriter)
        For intRegion As Integer = 1 To m_objMyRegions.Count
            With Me.Section6(intRegion)
                sw.NextLine()
                sw.Write(.W_LAYER)

                With .GRID
                    sw.NextLine()
                    sw.Write(.NSTEP)
                    sw.Write(.IPEAK)
                    sw.Write(.STFACT)
                End With

                With .DL
                    sw.NextLine()
                    sw.Write(.DLVS)

                    If CInt(.DLVS) = 0 Then
                        sw.NextLine()
                        sw.Write(.ND)

                        sw.NextLine()
                    Else
                        For intIndex As Integer = 0 To CInt(.DLVS) - 1
                            With .DLEVELS(intIndex)
                                sw.NextLine()
                                sw.Write(.ND)
                                sw.Write(.EDOND)
                                sw.Write(.SDD)
                                sw.Write(.GR_ND)

                                sw.NextLine()
                                sw.Write(.DDF)  '0.9.5
                                sw.Write(.DSIG_ND)
                                sw.Write(.DSIG_PD)
                            End With
                        Next
                    End If
                End With

                With .AL
                    sw.NextLine()
                    sw.Write(.ALVS)

                    If CInt(.ALVS) = 0 Then
                        sw.NextLine()
                        sw.Write(.NA)

                        sw.NextLine()
                    Else
                        For intIndex As Integer = 0 To CInt(.ALVS) - 1
                            With .ALEVELS(intIndex)
                                sw.NextLine()
                                sw.Write(.NA)
                                sw.Write(.EACPD)
                                sw.Write(.SDA)
                                sw.Write(.GR_NA)

                                sw.NextLine()
                                sw.Write(.ADF)  '0.9.5
                                sw.Write(.DSIG_NA)
                                sw.Write(.DSIG_PA)
                            End With
                        Next
                    End If
                End With

                With .DG
                    sw.NextLine()
                    sw.Write(.NUMDG)

                    For intIndex As Integer = 0 To CInt(.NUMDG) - 1
                        With .DGAUSSIANS(intIndex)
                            sw.NextLine()
                            sw.Write(.NDG)
                            sw.Write(.PEDG)
                            sw.Write(.SDDG)
                            sw.Write(.GR_NDG)
                            sw.Write(.GR_PEDG)
                            sw.Write(.GR_SDDG)
                        End With
                    Next
                    For intIndex As Integer = 0 To CInt(.NUMDG) - 1
                        With .DGAUSSIANS(intIndex)
                            sw.NextLine()
                            sw.Write(.GSIG_ND)
                            sw.Write(.GSIG_PD)
                            sw.Write(.GR_GSIG_ND)
                            sw.Write(.GR_GSIG_PD)
                        End With
                    Next
                End With

                With .AG
                    sw.NextLine()
                    sw.Write(.NUMAG)

                    For intIndex As Integer = 0 To CInt(.NUMAG) - 1
                        With .AGAUSSIANS(intIndex)
                            sw.NextLine()
                            sw.Write(.NAG)
                            sw.Write(.PEAG)
                            sw.Write(.SDAG)
                            sw.Write(.GR_NAG)
                            sw.Write(.GR_PEAG)
                            sw.Write(.GR_SDAG)
                        End With
                    Next
                    For intIndex As Integer = 0 To CInt(.NUMAG) - 1
                        With .AGAUSSIANS(intIndex)
                            sw.NextLine()
                            sw.Write(.GSIG_NA)
                            sw.Write(.GSIG_PA)
                            sw.Write(.GR_GSIG_NA)
                            sw.Write(.GR_GSIG_PA)
                        End With
                    Next
                End With

                With .TAILS
                    sw.NextLine()
                    sw.Write(.GDO)
                    sw.Write(.GAO)
                    sw.Write(.GR_GDO)
                    sw.Write(.GR_GAO)

                    sw.NextLine()
                    sw.Write(.ED)
                    sw.Write(.EA)
                    sw.Write(.GR_ED)
                    sw.Write(.GR_EA)

                    sw.NextLine()
                    sw.Write(.TSIG_ND)
                    sw.Write(.TSIG_PD)
                    sw.Write(.GR_TSIG_ND)
                    sw.Write(.GR_TSIG_PD)

                    sw.NextLine()
                    sw.Write(.TSIG_NA)
                    sw.Write(.TSIG_PA)
                    sw.Write(.GR_TSIG_NA)
                    sw.Write(.GR_TSIG_PA)
                End With

                sw.NextLine()
                sw.Write(.NTRAP)

                With .MIDGAP
                    sw.NextLine()
                    sw.Write(.MDDS)
                    sw.Write(.MADS)
                    sw.Write(.EDA)
                    sw.Write(.GR_MDDS)
                    sw.Write(.GR_MADS)
                    sw.Write(.GR_EDA)

                    sw.NextLine()
                    sw.Write(.MSIG_ND)
                    sw.Write(.MISG_PD)
                    sw.Write(.GR_MSIG_ND)
                    sw.Write(.GR_MSIG_PD)

                    sw.NextLine()
                    sw.Write(.MSIG_NA)
                    sw.Write(.MISG_PA)
                    sw.Write(.GR_MSIG_NA)
                    sw.Write(.GR_MSIG_PA)
                End With

                sw.NextLine()
                sw.Write(.HCON)
                sw.Write(.UCODP)
                sw.Write(.GR_HCON)
                sw.Write(.GR_UCODP)

                sw.NextLine()
                sw.Write(.EPDP)
                sw.Write(.DELTADP)
                sw.Write(.GR_EPDP)
                sw.Write(.GR_DELTADP)

                With .EDOS
                    sw.NextLine()
                    sw.Write(.NC)
                    sw.Write(.NV)
                    sw.Write(.GR_NV)
                    sw.Write(.GR_NC)
                End With

                With .GAP
                    sw.NextLine()
                    sw.Write(.EG)
                    sw.Write(.EGOPT)
                    sw.Write(.GR_EG)
                    sw.Write(.GR_ALPHA)
                    sw.NextLine()
                    sw.Write(.AEGOPT)
                    sw.Write(.DEGOPT)
                End With

                With .AFF
                    sw.NextLine()
                    sw.Write(.EAFF)
                    sw.Write(.GR_EAFF)

                    sw.NextLine()
                    sw.Write(.EPS)
                    sw.Write(.GR_EPS)
                End With

                With .FCM
                    sw.NextLine()
                    sw.Write(.EMOB)
                    sw.Write(.HMOB)
                    sw.Write(.GR_EMOB)
                    sw.Write(.GR_HMOB)
                End With

                With .EMASSES
                    sw.NextLine()
                    sw.Write(.EEFM)
                    sw.Write(.HEFM)
                    sw.Write(.GR_EEFM)
                    sw.Write(.GR_HEFM)
                End With

                With .MTUNN
                    sw.NextLine()
                    sw.Write(.RLOC_MT)
                    sw.Write(.DLOC_MT)
                    sw.Write(.GR_RLOC)
                    sw.Write(.GR_DLOC)
                End With

                sw.NextLine()
                sw.Write(.SCA_MAXANG)
                sw.Write(.SCA_MINANG)
            End With
        Next
    End Sub

    Private Sub WriteSection7(ByVal sw As SectionWriter)
        With Me.Section7
            .Items.Clear()
            For intWavelength As Integer = 1 To m_objMyWavelengths.Count
                Dim objSectionVFLUX As New Section7.SectionVFLUX

                sw.NextLine()
                sw.Write(m_objMyWavelengths.Item(intWavelength))

                With objSectionVFLUX
                    .LAMBDA = m_objMyWavelengths.Item(intWavelength)
                    sw.Write(.FLUX_1)

                    '0.9.6
                    sw.Write(.IFLUX)

                    sw.Write(.FILTER)
                    sw.Write(.FLUX_2)
                End With
                .Items.Add(objSectionVFLUX)
            Next
        End With
    End Sub

    Private Sub WriteSection8(ByVal sw As SectionWriter)
        With Me.Section8
            sw.NextLine()
            sw.Write(.W_EFOL)
            sw.Write(.W_IFOL)

            .Items.Clear()
            For intWavelength As Integer = 1 To m_objMyWavelengths.Count
                Dim dblValue As Double
                Dim objSectionVFOL As New Section8.SectionVFOL

                sw.NextLine()
                sw.Write(dblValue)
                If m_objMyWavelengths.Item(intWavelength) <> dblValue Then
                    Throw New System.IO.InvalidDataException
                Else
                    With objSectionVFOL
                        .LAMBDA = m_objMyWavelengths.Item(intWavelength)
                        sw.Write(.N_EFOL)
                        sw.Write(.K_EFOL)

                        '0.9.6
                        'sw.Write(.K_IFOL)
                        'sw.Write(.N_IFOL)
                        sw.Write(.N_IFOL)
                        sw.Write(.K_IFOL)
                    End With
                    .Items.Add(objSectionVFOL)
                End If
            Next
        End With
    End Sub

    Private Sub WriteSection9(ByVal sw As SectionWriter)
        With Me.Section9
            sw.NextLine()
            sw.Write(.W_IBOL)
            sw.Write(.W_EBOL)

            .Items.Clear()
            For intWavelength As Integer = 1 To m_objMyWavelengths.Count
                Dim dblValue As Double
                Dim objSectionVBOL As New Section9.SectionVBOL

                sw.NextLine()
                sw.Write(dblValue)
                If m_objMyWavelengths.Item(intWavelength) <> dblValue Then
                    Throw New System.IO.InvalidDataException
                Else
                    With objSectionVBOL
                        .LAMBDA = m_objMyWavelengths.Item(intWavelength)
                        sw.Write(.N_IBOL)
                        sw.Write(.K_IBOL)

                        '0.9.6
                        'sw.Write(.K_EBOL)
                        'sw.Write(.N_EBOL)
                        sw.Write(.N_EBOL)
                        sw.Write(.K_EBOL)
                    End With
                    .Items.Add(objSectionVBOL)
                End If
            Next
        End With
    End Sub

    Private Sub WriteSection10(ByVal sw As SectionWriter)
        For intRegion As Integer = 1 To m_objMyRegions.Count
            With Me.Section10(intRegion)
                .Items.Clear()
                For intWavelength As Integer = 1 To m_objMyWavelengths.Count
                    Dim dblValue As Double
                    Dim objSectionVOP As New Section10.SectionVOP

                    sw.NextLine()
                    sw.Write(dblValue)
                    If m_objMyWavelengths.Item(intWavelength) <> dblValue Then
                        Throw New IO.InvalidDataException
                    Else
                        With objSectionVOP
                            .LAMBDA = m_objMyWavelengths.Item(intWavelength)
                            sw.Write(.RILAM)
                            sw.Write(.ALPHA)
                        End With
                        .Items.Add(objSectionVOP)
                    End If
                Next
            End With
        Next
    End Sub

End Class
